<?php
/*
 * inc-adminHome.php
 * Retral/CSCD494 Winter 2009
 * Eastern Washington University
 *
 * File Description:
 * Home page for users with role code admin
 * 
 * Other:
 * 
 */
if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] != "" && $_SESSION['roleCode'] == "admin")
{
	$greet = $_SESSION['loggedIn'];
	
	echo "<span class=\"header-text\">WELCOME, $greet</span><br>";
?>
	<b>Admin</b> homepage placeholder content. 
	<br><hr>
	<a href="logout.php">Logout</a>

	<?php
	$conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);
	
	// This is the value in the database that the database uses
	// to signify an admin response revision. Meaning of the 
	// numbers are not documented here because it will not
	// get updated.
	$requestValue = 1;

	$query = '
			SELECT COUNT(question_id) AS "COUNT" FROM change_request
			INNER JOIN revision_type 
			ON change_request.request_code=revision_type.request_code
			WHERE revision_type.rev_type = :RQ';
		$stmt = oci_parse($conn, $query);
		oci_bind_by_name($stmt, ':RQ', $requestValue);
		if(!oci_execute($stmt))
			print "<p>Bad query for CR count</p>";

		$result = oci_fetch_assoc($stmt);

		print "<h3>You have ".$result['COUNT']." questions awaiting ";
		print "<a href='?page=request'>approval</a>.</h3>";

	oci_close($conn);
}
else
{
	echo "Invalid Credentials";
	header("Location:index.php?page=login&ld=0");
}
?>
